# pip install pymongo==3.9
# python 11
from pymongo import MongoClient

#  创建数据库连接对象
# client = MongoClient(host="127.0.0.1", port=27017, username="tasks", password="admin123456!")
client = MongoClient(host="127.0.0.1", port=27017)

#  选择一个数据库
db = client['tasks']
#  数据库中开了权限认证后，需要下一行代码
#  输入超级管理员账号和密码
db.authenticate('tasks', 'admin123456!')
#  选择一个集合,没有的话会新建的 tasks为数据库， test1为集合
task_db = client['tasks']
col = task_db['test1']
query = {"1":"1"}
# result = col.insert_one(query)
result2 = col.find_one(query)
print(result2)
